<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> __课程管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="__ROOT__/favicon.ico">
    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__CSS__/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="__CSS__/animate.css" rel="stylesheet">
    <link href="__CSS__/style.css?v=4.1.0" rel="stylesheet">
    <!--自定义css-->
    <link href="__CSS__/admin/Course/read.css" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="container">

        <form action="{:url('Course/select')}" class="row" method="post">
            <select class="col-md-3" onchange="onchaange(this)" id="change">
                {volist name="array2" id="value"}
                {if condition="($value.id eq 1)"}
                <option value="{$value.name}" selected="true">{$value.name}</option>
                {else/}
                <option value="{$value.name}">{$value.name}</option>
                {/if}

                {/volist}
            </select>


            <select name="category_name" class="col-md-3" id="fine">
                {volist name="array3" id="value"}
                <option value="{$value.record_name}">{$value.record_name}</option>
                {/volist}
            </select>

            <input type="text" name="name"   class="col-md-3"   id="input">
            <input type="submit" value="GO" class="col-md-3" >

        </form>
    </div>
    <div class="row">

        {block name="row"}


        {volist name="array" id="value"}
        <div class="col-sm-4" style="width:30% ;margin: 1%;height: 25rem;position: relative;background-color: #a8a2a2;border-radius: 0.5rem">


            <div style="float: left; width:100%;height: 70%;background-color: rgba(255,255,255,0)">
                <h2 style="color: #000000;">{$value.record_name}</h2>

                <h6 style="line-height: 250%;color: #272a27;">
                    <p class="contentfont" >难度 ：{$value.difficulty}</p>
                    <p  class="contentfont">课程简介 ：{$value.introduce}</p>
                    <p  class="contentfont">收费:{$value.charge}</p>

                </h6>

            </div>
            <div style=" width:100%;height: 20%; clear: both" >
                <div class="button-left floats "><a href="{:url('Course/updateshow')}?id={$value.id}">修改</a></div>
                <div class="button-right floats " onclick="deletes('{$value.id}')">删除</div>
            </div>

        </div>

        {/volist}

        {/block}

    </div>
</div>
<!-- 全局js -->
<script src="__JS__/jquery-1.11.3.js"></script>
<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="__JS__/content.js?v=1.0.0"></script>
<script>
    var chengeurl = "{:url('Course/change')}";

    $(document).ready(function () {
        $('.contact-box').each(function () {
            animationHover(this, 'pulse');
        });


    });

    function onchaange(id) {
//        alert(id.value);
        $.ajax({
            url: chengeurl,
            type: "post",
            dataType: "json",
            data: {
                name: id.value
            },
            success: function (data) {
//            alert(data[0].record_name)
                $("#fine").empty();
                for (var i = 0; i < Object.keys(data).length; i++) {  //获取data长度   循环遍历出来
                    $("#fine").append('<option value=' + data[i].id + '>' + data[i].record_name + '</option>')
                }
            },
            error: function (e) {
                alert(e.response)
            }
        })
    }


    var successurl = "{}";
    var deleteurl = "{:url('Course/delete')}"
    function deletes(id) {
        if (confirm("你确定要删除这个课程吗？")) {
            $.ajax({
                url: deleteurl + "?id=" + id,
                type: "get",
                dataType: "text",
                data: null,
                success: function (data) {
//                alert(data)
                    if (data == "1") {
                        alert("删除成功")
                        location.href = successurl;
                    } else {
                        alert("删除失败")
                    }

                },
                error: function (e) {
                    alert(e.response)
                }
            })

        }
    }

</script>
<div style="margin-bottom: 0px ;text-align: center;position: fixed;bottom: 0px;width: 100%;">
    {$page}
    <!--{$array->render()}-->
</div>
</body>

</html>
